package com.realtyManage.springboot.Utils;

import com.realtyManage.springboot.Dao.UserRepository;
import com.realtyManage.springboot.Service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/*
*权限认证
*/
@Component
public class QxUtil{

    @Autowired
    private IUserService userService;

    private static QxUtil qxUtil;

    @PostConstruct
    public void init(){
        qxUtil = this;
        qxUtil.userService = this.userService;
    }

    public static String Rz(String uid, String jb){    //用户id  功能权限
        String result = "fail";
        System.out.println("============>"+uid);
        if (qxUtil.userService.findQx(uid).length() > 0){
            String jbs[] = qxUtil.userService.findQx(uid).split(",");
            for (String db : jbs){
                if (db.equals(jb)){
                    result = "success";
                }
            }
        }
        return result;
    }

}
